<!doctype html>
<html>
<head>
    <meta charset="utf-8">
    <title>提现记录-{$webname}</title>
    {Model_Supplier::css("style.css,base.css,extend.css,admin.css",'brokerage')}
    {Common::js("jquery.min.js")}
    {Common::js('layer/layer.js')}

    <style>
        .show-link
        {
            color: #28b463;
            font-size: 14px;
        }
    </style>
</head>

<body>
    <div class="supplier-main-block">
        <div class="content-box">
            <div class="frame-box">
                <div class="finance-content">
                    <div class="finance-bloock">
                        <div class="census-item census-item-float-left">
                            <ul>

                                <li class="clearfix" style="width: 120px">
                                    <!--                                    <strong class="item-bt"></strong>-->
                                    <div class="item-bt">
                                        <select name="" class="attr-select" id="status" style="padding-left: 5px;">
                                            <option value="0">提现状态</option>
                                            <option value="1" {if $status==1}selected{/if}>待审核</option>
                                            <option value="2" {if $status==2}selected{/if}>未通过</option>
                                            <option value="3" {if $status==3}selected{/if}>已提现</option>
                                        </select>
                                    </div>
                                </li>
                                <li class="clearfix">
                                    <div class="item-nr">
                                        <a href="javascript:;"  class="choose-btn choose-btn-search">搜索</a>
                                    </div>
                                </li>
                                <li class="clearfix" >
                                    <div class="item-nr">
                                        <span class="choose-btn" id="approval_apply">申请提现</span>
                                    </div>
                                </li>
                                <li class="clearfix">
                                    <div class="item-nr mt-4 ml-100">
                                        <span class="mr-5">可提现金额：<span class="color-red f-18">￥{$price_arr['allow_price']}</span></span>
                                        <span class="mr-5">提现审核中：<span class="color-orange f-18">￥{$price_arr['withdraw_price_approval']}</span></span>
                                        <span>已提现金额：<span class="color-green f-18">￥{$price_arr['withdraw_price_finish']}</span></span>
                                    </div>
                                </li>
                                <li class="clearfix" style="float: right">
                                    <div class="item-nr fr">
                                        <span class="choose-btn" id="excel-btn">导出Excel</span>
                                    </div>
                                </li>
                            </ul>
                        </div>
                        <div class="cw-table clearfix">

                            <table width="100%" border="0" padding_top=VUSX4t >
                                <tbody>
                                <tr id="record_list_header">
                                    <th width="10%">申请时间</th>
                                    <th width="20%">提现金额</th>
                                    <th width="10%">提现到</th>
                                    <th width="10%">提现状态</th>
                                    <th width="15%">操作</th>
                                </tr>
                                {loop $list $l}
                                <tr>
                                    <td>{$l['addtime']}</td>
                                    <td><span style="color: red">￥{$l['withdrawamount']}</span></td>
                                    <td>{$l['proceeds_type_title']}</td>
                                    <td>{if $l['status']==0} <span style="color: red">待审核</span>{elseif $l['status']==1}已提现{else}未通过{/if}</td>
                                    <td><a href="{$cmsurl}supplier_brokerage/approval_show/id/{$l['id']}" data-id="{$l['id']}" class="show-link">详情</a></td>
                                </tr>
                                {/loop}
                                </tbody>
                            </table>
                        </div>
                        <div class="view-block-table">
                            {$pageinfo}
                        </div>
                    </div>
                </div><!-- 财务总览 -->
            </div>

        </div>


        <div class="hide pd-20" id="spotSelectBox">
            <div class="tixian-item">
                <form id="chkfrm">
                    <ul>
                        <li class="clearfix">
                            <strong class="item-bt">提现金额：</strong>
                            <div class="item-nr">
                                <input type="number" class="default-text w200" name="withdrawamount" id="withdrawamount" data-max="{$price_arr['allow_price']}" value="$price_arr['allow_price']">
                                <span class="usable">可提现金额¥{$price_arr['allow_price']}</span>
                                <span class="error-txt" style="display: none">请填写正确的提现金额</span>
                            </div>
                        </li>
                        <li class="clearfix">
                            <strong class="item-bt">账户类型：</strong>
                            <div class="item-nr">
                                <label id="bankcard" class="pay-way">
                                    <input type="radio" value="1" name="proceeds_type" {if $info['proceeds_type'] == 1} checked {/if} >银行卡</label>
                                <label id="alipay" class="pay-way">
                                    <input type="radio" value="2" name="proceeds_type" {if $info['proceeds_type'] == 2} checked {/if} >支付宝</label>
                                <label id="wechat" class="pay-way">
                                    <input type="radio" value="3" name="proceeds_type" {if $info['proceeds_type'] == 3} checked {/if} >微信</label>
                            </div>
                        </li>
                        <li class="clearfix bankcard-msg">
                            <strong class="item-bt">银行卡号：</strong>
                            <div class="item-nr">
                                <input type="text" class="default-text w370" name="bankcardnumber" value="{$info['bankcardnumber']}" >
                                <span class="error-txt" style="display: none">请填写银行卡卡号</span>
                            </div>
                        </li>
                        <li class="clearfix bankcard-msg">
                            <strong class="item-bt">账户名：</strong>
                            <div class="item-nr">
                                <input type="text" class="default-text w370" name="bankaccountname" value="{$info['bankaccountname']}" >
                                <span class="error-txt" style="display: none">请填写银行卡账户名</span>
                            </div>
                        </li>
                        <li class="clearfix bankcard-msg">
                            <strong class="item-bt">开户银行：</strong>
                            <div class="item-nr">
                                <input type="text" class="default-text w370" name="bankname" value="{$info['bankname']}" >
                                <span class="error-txt" style="display: none">请填写开户行</span>
                            </div>
                        </li>
                        <li class="clearfix alipay-msg" style="display: none">
                            <strong class="item-bt">支付宝账号：</strong>
                            <div class="item-nr">
                                <input type="text" class="default-text w370" name="alipayaccount" value="{$info['alipayaccount']}" >
                                <span class="error-txt" style="display: none">请填写正确的支付宝账户</span>
                            </div>
                        </li>
                        <li class="clearfix wechat-msg" style="display: none">
                            <strong class="item-bt">微信账号：</strong>
                            <div class="item-nr">
                                <input type="text" class="default-text w370" name="wechataccount" value="{$info['wechataccount']}" >
                                <span class="error-txt" style="display: none">请填写正确的微信账户</span>
                            </div>
                        </li>
                        <li class="clearfix">
                            <strong class="item-bt">备注说明：</strong>
                            <div class="item-nr">
                                <textarea class="bz-txt" style="resize: none"  name="description">{$info['description']}</textarea>
                            </div>
                        </li>
                        <li class="clearfix">
                            <strong class="item-bt"></strong>
                            <div class="item-nr btn-block">
                                <a class="tj-btn" href="javascript:;">提交申请</a>
                            </div>
                        </li>
                    </ul>
                </form>
            </div>
        </div>
        <!-- 选择门票 -->
    </div>
</body>
</html>

<script>
	var tx_price = "{$price_arr['allow_price']}";
    $(function(){
        //打开页面时就选择到具体的栏目
        let proceeds_type = "{$info['proceeds_type']}";
        if(proceeds_type == 2){
            $(".alipay-msg").show();
            $(".bankcard-msg").hide();
            $(".wechat-msg").hide();
        }
        if(proceeds_type == 3){
            $(".wechat-msg").show();
            $(".alipay-msg").hide();
            $(".bankcard-msg").hide()
        }

        $("#alipay").on("click",function(){
            $(".alipay-msg").show();
            $(".bankcard-msg").hide();
            $(".wechat-msg").hide();
        });
        $("#bankcard").on("click",function(){
            $(".alipay-msg").hide();
            $(".wechat-msg").hide();
            $(".bankcard-msg").show()
        });
        $("#wechat").on("click",function(){
            $(".wechat-msg").show();
            $(".alipay-msg").hide();
            $(".bankcard-msg").hide()
        })
    })
</script>
<script>
    $(function () {
        $('#withdrawamount').change(function () {
            let withdrawamount = "{$price_arr['allow_price']}";
            let amount = $(this).val();
            if(parseInt(amount) > parseInt(withdrawamount))
            {
                layer.msg('提现金额已超过最大金额:'+withdrawamount,{icon:5,time:2000});
                return ;
            }
            console.log(amount,withdrawamount)
        })
        $('.hd-menu a').removeClass('cur');
        $('.hd-menu #brokerage').addClass('cur');
        $('#brokerage_approval').addClass('on');

        $('.choose-btn-search').click(function () {
            var status = $('#status').val();
            var url = '{$cmsurl}supplier_brokerage/approval?status='+status;
            location.href = url;
        });
        $('.approval_apply').click(function () {
            $('.st-popup-box ').show();
        })

        $('.tj-btn').click(function () {
			var price = $("#withdrawamount").val();
			if(parseFloat(price)>parseFloat(tx_price)){
				layer.msg('提现金额大于可提现金额！',{icon:5,time:2000});
				return false;
			}
			if(price<0.01){
				layer.msg('提现金额出错！',{icon:5,time:2000});
				return false;
			}
			var proceeds_type = $("[name='proceeds_type']:checked").val();
			var bankcardnumber = $("[name='bankcardnumber']").val();
			var bankaccountname = $("[name='bankaccountname']").val();
			var bankname = $("[name='bankname']").val();
			var alipayaccount = $("[name='alipayaccount']").val();
			var wechataccount = $("[name='wechataccount']").val();
			if(proceeds_type==1){
                if(!bankcardnumber || !bankaccountname || !bankname){
                    layer.msg('请填写完整信息！',{icon:5,time:2000});
                    return false;
                }
            }else if(proceeds_type==2){
                if(!alipayaccount){
                    layer.msg('请填写支付宝账号！',{icon:5,time:2000});
                    return false;
                }
            }else if(proceeds_type==3){
                if(!wechataccount){
                    layer.msg('请填写微信号！',{icon:5,time:2000});
                    return false;
                }
            }else{
                layer.msg('请选择提现方式！',{icon:5,time:2000});
                return false;
            }

            $.ajax({
                dataType:'json',
                type:'post',
                data:$('#chkfrm').serialize(),
                url:'{$cmsurl}'+'supplier_brokerage/ajax_save_approval',
                success:function (data) {
                    if(data.status==1)
                    {
                        layer.msg('申请提交成功',{icon:1,time:2000},function () {
                            var url = '{$cmsurl}supplier_brokerage/approval';
                            location.href = url;
                        })
                    }
                    else
                    {
                        layer.msg('保存失败',{icon:5,time:1000})
                    }
                }
            })
        })

        //选择提现
        $('#approval_apply').on('click',function(){
            layer.open({
                type: 1,
                title: '申请提现',
                area: ['800px','670px'],
                content: $("#spotSelectBox")
            })
        });

        //导出EXcel
        $("#excel-btn").click(function () {
            var status = $('#status').val();
            var url = '{$cmsurl}supplier_brokerage/ajax_excel?status='+status;
            window.open(url);
        })
    })

</script>
